<template>

			
	
			
					<view class="example">
						<!-- 基础用法，不包含校验规则 -->
						<uni-forms ref="baseForm" >
							
							<uni-forms-item label="" >
								<uni-easyinput v-model="memberInfo.memberName" placeholder="请输入会员名称" />
							</uni-forms-item>
							<uni-forms-item label="" >
								<uni-easyinput v-model="memberInfo.memberPhone" type="number" placeholder="请输入会员手机号" />
							</uni-forms-item>
							
					
							
								<button type="primary"  @click="submit()">保存</button>
						
						
						</uni-forms>
					</view>
				
			
					
				
</template>

<script>
	import http from '@/store/http.js'
	export default {
			data() {
				return {
					memberInfo:{
						id:"",
						memberName:"",
						memberPhone:"",
						
						
					},
					cardTypeList: [{
							text: '余额',
							value: 1
						}, {
							text: '次数',
							value: 2
						}],
				
					
				}
			},
			onLoad() {
				
				
				
				
				var jsonString =uni.getStorageSync('editMemberInfo');
				if(jsonString){
					var member=JSON.parse(jsonString);
					this.$data.memberInfo.id=member.id;
					this.$data.memberInfo.memberName=member.memberName;
					this.$data.memberInfo.memberPhone=member.memberPhone;
					console.log(111)
				}else{
					console.log(222)
				}
				
			},
			watch: {
				
			},
			mounted() {
				
			},
	
			methods:{
				change(e) {
					this.single = e
					console.log('change事件:', this.single = e);
				},
				changeLog(e) {
					console.log('change事件:', e);
				},
				maskClick(e){
					console.log('maskClick事件:', e);
				},
				submit(){
					var self=this;
					
					var memberData=this.$data.memberInfo;
					
					if(memberData.memberName==0){
						uni.showToast({
							title:"请输入会员姓名",
							icon:'none'
						})
						return false;
					}
					if(memberData.memberPhone==0){
						uni.showToast({
							title:"请输入会员手机号",
							icon:'none'
						})
						return false;
					}
					
					
					if(memberData.memberType==1){
						memberData.memberValue=memberData.memberValue*100;
					}
					http.post("/api/member/editMember",memberData,(data)=>{
						if(data.status){
							
							uni.showToast({
								title:"修改成功",
								icon:'none'
							})
							 
							uni.redirectTo({
								url:"/pages/member/memberDetail"
							})
							
						}else{
							uni.showToast({
								title:data.msg,
								icon:'none'
							})
						}
						
					});
					
					
				},
			}
		}
</script>

<style>
	.example-body {
			background-color: #fff;
			padding: 10px;
		}
		.example {
				padding: 15px;
				background-color: #fff;
			}
		
			.segmented-control {
				margin-bottom: 15px;
			}
		
			.button-group {
				margin-top: 15px;
				display: flex;
				justify-content: space-around;
			}
		
			.form-item {
				display: flex;
				align-items: center;
			}
		
			.button {
				display: flex;
				align-items: center;
				height: 35px;
				margin-left: 10px;
			}
</style>